package types

import (
	"strings"
)

// 小说的写作状态
type WriteState uint8

const (
	// 连载中
	WriteStateOngoing WriteState = iota
	// 已完结
	WriteStateFinished
	// 暂停
	WriteStatePaused
	// 未知状态
	WriteStateUnknow
)

func NewWriteState(status string) WriteState {
	if strings.Contains(status, "连载") {
		return WriteStateOngoing
	}
	if strings.Contains(status, "完") {
		return WriteStateFinished
	}

	return WriteStateUnknow
}
func (w WriteState) String() string {
	switch w {
	case WriteStateOngoing:
		return "连载中"
	case WriteStateFinished:
		return "已完结"
	case WriteStatePaused:
		return "暂停"
	default:
		return "其他状态"
	}
}
func (w WriteState) IsZero() bool {
	return w == 0
}
func (w WriteState) IsFinished() bool {
	return w == WriteStateFinished
}
func (w WriteState) IsOngoing() bool {
	return w == WriteStateOngoing
}
func (w WriteState) IsPaused() bool {
	return w == WriteStatePaused
}
func (w WriteState) IsOther() bool {
	return w == WriteStateUnknow
}
func (w WriteState) IsValid() bool {
	return w.IsFinished() || w.IsOngoing() || w.IsPaused() || w.IsOther()
}
func (w WriteState) IsValidStatus() bool {
	return w.IsFinished() || w.IsOngoing() || w.IsPaused()
}
func (w WriteState) IsInvalid() bool {
	return !w.IsValid()
}
